
package com.htd.htdapmservice.xxljob;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSONObject;
import com.htd.htdapmcommon.enums.AlarmsStatusEnum;
import com.htd.htdapmdmo.OneAlertAlarmsRecordInfo;
import com.htd.htdapmservice.dao.AlarmsInfoDao;
import com.htd.htdapmservice.dao.OneAlertAlarmsRecordDao;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;


@JobHandler(value="syncAlarmInfoStatusJobHandler")
@Component
@Deprecated
public class SyncAlarmInfoStatusJobHandler extends IJobHandler  {
    private static final Logger logger = LoggerFactory.getLogger(SyncAlarmInfoStatusJobHandler.class);

    @Autowired
    private AlarmsInfoDao alarmsInfoDao;
    
    @Autowired 
    private OneAlertAlarmsRecordDao oneAlertAlarmsRecordDao;

	@Override
	public ReturnT<String> execute(String param) throws Exception {

		logger.info("syncAlarmInfoStatusJobHandler Entrance, param : {}", new Object[]{JSONObject.toJSONString(param)});
        List<OneAlertAlarmsRecordInfo> oneAlertAlarmsRecordInfoList =new ArrayList<OneAlertAlarmsRecordInfo>();
        
        try{
        	
            oneAlertAlarmsRecordInfoList = oneAlertAlarmsRecordDao.getListByStatus(AlarmsStatusEnum.ACTIVE.getCode());
            
            if (oneAlertAlarmsRecordInfoList!=null &&oneAlertAlarmsRecordInfoList.size()>0) {
      		  alarmsInfoDao.updateAlarmInfoStatus(oneAlertAlarmsRecordInfoList);
      	  	}
        } catch (Exception e){
            logger.error("syncAlarmInfoStatusJobHandler error:", e);
        }
		return null;
	}



}
